
<meta title="用户列表"/>
<form class="form-inline" id="userSearchForm" s="form"
      s-form="{action: function(){S.N('#page').val(1); userGrid.refresh();}}">
    <input type="text" name="name" class="form-control" placeholder=""/>
    <input type="hidden" name="page" value="1" id="page"/>
    <!--<input type="hidden" name="pageSize" value="100"/>-->
    <input type="submit" class="btn btn-success" value="查找"/>
</form>
<div class="s-ui-grid-action">
    <input type="button" class="btn btn-sm btn-info" value="新建" s-click="createuser()"/>
    <input type="button" class="btn btn-sm btn-danger" value="删除" s-click="deleteusers()"/>
</div>
<table s="check,nda,datac" s-data="S.get('/api/admin/user', S.N('#userSearchForm').serialize())" id="userGrid"
       class="table table-striped table-hover" style="width: 100%;">
    <thead>
    <tr>
        <th><input type="checkbox" s-check-role="checkall-h"/></th>
        
            <th >名称</th>
        
            <th >头像</th>
        
            <th >创建时间</th>
        
        <th style="width: 15%;" class="text-right">操作</th>
    </tr>
    </thead>
    <tbody s="loop" s-data-filter="'list'">
    <tr s-loop-role="empty">
        <td colspan="11">
            <div class="s-ui-none-data-info text-center"><i class="fa fa-info-circle text-info"></i> 未查询到数据</div>
        </td>
    </tr>
    <tr s-loop-role="loading">
        <td colspan="11">
            <div class="text-center" style="padding: 20px;"><i class="fa fa-spinner fa-spin fa-3x fa-fw"></i></div>
        </td>
    </tr>
    <tr s-loop-role="row" s-check-role="i" s="datac,row">
        <td><input type="checkbox" s-check-role="h"/></td>
            <td s="tpl"><img src="{%=this.icon%}" style="max-width: 50px; max-height: 50px;"/></td>
            <td name="name"/></td>
            <td name="createTime"/></td>
        
        <td class="text-right">
            <input type="button" class="btn btn-sm btn-link" s-click="edituser(this)" value="编辑"/>
        </td>
    </tr>
    </tbody>
    <tfoot>
    <tr>
        <td colspan="11" class="s-ui-pagination-wrapper">
            <ul s="pagination" id="userBillPagination"
                s-pagination="{action:function(){S.N('#page').val(this); userGrid.refresh()}}"
                class="pagination pagination-sm pull-right" style="margin: 0">
            </ul>
            <div class="s-ui-pagination-info pull-right">共有<span name="allCount"></span>条记录</div>
        </td>
    </tr>
    </tfoot>
</table>
<script type="text/javascript">
    var userGrid = S.S('#userGrid');

    function createuser() {
        S.popupOpen('adminUser/user-add.html').done(function (flag) {
            flag && userGrid.refresh();
        })
    }

    function deleteusers() {
        var ids = userGrid.getCheckedData('id');
        if (ids.length == 0) {
            S.notice("请选择需要删除的用户", 'warning');
            return;
        }
        S.confirm("确认删除所选用户吗？").done(function () {
            S.remove("/api/admin/user/" + ids.join("_")).done(function () {
                userGrid.refresh();
            });
        });
    }
    function edituser(s) {
        S.popupOpen("adminUser/user-edit.html", {user: s.parent().data()}).done(function(user){
            if(user){userGrid.refresh();}
        })
    }
</script>